﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using MyGeneration.dOOdads;
using MethodIT.Helper;

using Hr20.DAL;
using Hr20.BLL;
using Hr20.ProcessFlow;


namespace Appraisal.Web.ZB
{
    public partial class BidderReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                KP_Subject s = new KP_Subject();
                s.LoadAll();
                FunctionSet.FillListControl(dplSubject, s.DefaultView.Table, KP_Subject.ColumnNames.SubjectName, KP_Subject.ColumnNames.ID,"全部");

            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            VW_Tender_Report vw = new VW_Tender_Report();
            if (txtName.Text !="")
            {
                vw.Where.TenderName.Value = "%" + txtName.Text + "%";
                vw.Where.TenderName.Operator = WhereParameter.Operand.Like;
            }
            if (dplSubject.SelectedValue != "-1")
            {
                vw.Where.SubID.Value = HelperDigit.ConvertToInt32(dplSubject.SelectedValue);
            }
            if (txtDate1.Text!="")
            {
                vw.Where.SubBeginDate.Value = DateTime.Parse(txtDate1.Text);
                vw.Where.SubBeginDate.Operator = WhereParameter.Operand.GreaterThanOrEqual;
            }
            if (txtDate2.Text != "")
            {
                vw.Where.SubBeginDate.Value = DateTime.Parse(txtDate2.Text);
                vw.Where.SubBeginDate.Operator = WhereParameter.Operand.LessThanOrEqual;
            }
            if (rblType.SelectedValue != "-1")
            {
                vw.Where.KpType.Value = rblType.SelectedValue;
            }
            vw.Query.Load();
            dg.DataSource = vw.DefaultView;
            dg.DataBind();
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            FunctionSet.ExportExcel(Response, dg, "UTF-8");
        }
    }
}
